<?php
use Home\Controller\IndexController;
class xiadan{
	var $showplist = '';
	
	function getleibie(){
		global $db;
		$db->ExeQuerySql("SELECT * FROM `cu_gdlb`");
		$this->showplist='<option value="请选择...">请选择...</option>';
		while ($row = $db->GetFetchArray()){
			$this->showplist=$this->showplist.'<option value="'.$row['lbmc'].'">'.$row['lbtitle'].'</option>';
		}
		return $this->showplist;
	}
	function checkycl($ycl){
		$rtn = false;//默认返回假
		$xmlDoc = new DOMDocument();
		if (file_exists("./tpl/ycl/set.xml") && $xmlDoc->load("./tpl/ycl/set.xml")) {
			$x = $xmlDoc->documentElement;
			foreach ($x->childNodes AS $item)
			{
				if ($item->nodeName == $ycl && $item->nodeValue == 'True') {
					$rtn = true;
					break;
				}
			}
		}else {
			$rtn = false;
		}		
		return $rtn;
	}
	//在预处理直接归档的过程中，服务器在ycl文件夹下找到chs.xml获取英文节点的中文解释并存储在“服务内容”字段中。
	function putyclnodeinchs($node) {
		$rtn = '无法获取';
		try {
			$xmlDoc = new DOMDocument();
			
			if (file_exists("./tpl/ycl/chs.xml") && $xmlDoc->load("./tpl/ycl/chs.xml")) {
				$x = $xmlDoc->documentElement;
				$rtn = false;
				foreach ($x->childNodes AS $item)
				{
					if ($item->nodeName == $node) {
						$rtn = $item->nodeValue;
						break;
					}
				}
			}
		} catch (Exception $e) {
			$rtn = $e->getMessage();
		}
		return $rtn;
	}
	function submitYCL($posti){
		global $db;
		global $now_em;
		if ($posti){
			if (empty($posti['snp'])){
				return false;
			}elseif (!empty($posti['snp'])){
				$x = $this->putyclnodeinchs($posti['snp']);
			}
			$sql = "insert into cu_glxq(submitnumber,contactnumber,gdlbvalue,content,time,orderman,customername,idnumber,idcardaddress,isend,archivecontent) values ('$posti[shengaohao]','$posti[lianxihao]','$posti[xdlb]','$x',now(),'$posti[shouligonghao]','$posti[kehuxingming]','$posti[cridnumber]','$posti[craddress]','直接归档','预处理系统自动归档')";
			$db->ExeSql($sql);
			$db->ExeQuerySql("select * from cu_glxq where submitnumber='$posti[shengaohao]' and contactnumber='$posti[lianxihao]'");
			if($db->FetchRow())
			{
				return true;
			}else{
				return false;
			}
		}else{
			return false;
		}
	}
	function submitGD($posti){
		global $db;
		global $now_em;
		if ($posti){
			if (!empty($posti['snp'])){
			$isYCL = $this->checkycl($posti['snp']);
				if ($isYCL){
					return false;
				}
			}elseif (empty($posti['snp']) && $posti['xdlb'] == "投诉-产品质量"){
				return false;
			}
			$sql = "insert into cu_glxq(submitnumber,contactnumber,gdlbvalue,content,time,orderman,customername,idnumber,idcardaddress) values ('$posti[shengaohao]','$posti[lianxihao]','$posti[xdlb]','$posti[fuwuneirong]',now(),'$posti[shouligonghao]','$posti[kehuxingming]','$posti[cridnumber]','$posti[craddress]')";
			$db->ExeSql($sql);
			$db->ExeQuerySql("select * from cu_glxq where submitnumber='$posti[shengaohao]' and contactnumber='$posti[lianxihao]'");
			if($db->FetchRow())
			{
				return true;
			}else{
				return false;
			}
		}else{
			return false;
		}
	}
}